<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生考试管理系统 - 在线考试</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        .exam-container {
            max-width: 800px;
            margin: 0 auto;
        }
        .question-card {
            margin-bottom: 20px;
        }
        .timer {
            font-size: 1.5rem;
            font-weight: bold;
            text-align: right;
            color: red;
        }
        .question-number {
            font-weight: bold;
            margin-bottom: 10px;
        }
        .question-content {
            margin-bottom: 15px;
        }
        .option {
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container">
        <a class="navbar-brand" href="dashboard.html">
            <i class="fa fa-graduation-cap mr-2"></i>学生考试管理系统
        </a>

        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="dashboard.html">仪表盘</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="exams.html">在线考试</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="examResult.html">成绩查询</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="profile.html">个人信息</a>
                </li>
            </ul>

            <ul class="navbar-nav ms-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <i class="fa fa-user-circle mr-1"></i>张三 (20230001)
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li><a class="dropdown-item" href="profile.html">个人信息</a></li>
                        <li><a class="dropdown-item" href="changePassword.html">修改密码</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="login.html">退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

<!-- 主内容 -->
<div class="container mt-4 exam-container">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-file-text-o mr-2"></i>Java程序设计 考试
                    <div class="timer" id="examTimer">剩余时间: 1:59:59</div>
                </div>
                <div class="card-body">
                    <h4 class="mb-4">考试说明</h4>
                    <p>本考试包含单选题、多选题、判断题和简答题，总分100分，考试时间120分钟。请认真作答，考试过程中禁止切屏。</p>
                    <p>考试时间: 2025-06-20 09:00 - 2025-06-20 11:00</p>
                    <p>考试时长: 120 分钟</p>

                    <hr>

                    <form action="submitExam" method="post">
                        <input type="hidden" name="examId" value="1">

                        <!-- 单选题 -->
                        <div class="question-card">
                            <div class="question-number">1. 单选题 (10分)</div>
                            <div class="question-content">以下哪个是Java的基本数据类型？</div>
                            <div class="option">
                                <input type="radio" id="q1a" name="q1" value="A">
                                <label for="q1a">A. String</label>
                            </div>
                            <div class="option">
                                <input type="radio" id="q1b" name="q1" value="B">
                                <label for="q1b">B. int</label>
                            </div>
                            <div class="option">
                                <input type="radio" id="q1c" name="q1" value="C">
                                <label for="q1c">C. ArrayList</label>
                            </div>
                            <div class="option">
                                <input type="radio" id="q1d" name="q1" value="D">
                                <label for="q1d">D. HashMap</label>
                            </div>
                        </div>

                        <!-- 多选题 -->
                        <div class="question-card">
                            <div class="question-number">2. 多选题 (15分)</div>
                            <div class="question-content">以下哪些是面向对象的特性？</div>
                            <div class="option">
                                <input type="checkbox" id="q2a" name="q2" value="A">
                                <label for="q2a">A. 封装</label>
                            </div>
                            <div class="option">
                                <input type="checkbox" id="q2b" name="q2" value="B">
                                <label for="q2b">B. 继承</label>
                            </div>
                            <div class="option">
                                <input type="checkbox" id="q2c" name="q2" value="C">
                                <label for="q2c">C. 多态</label>
                            </div>
                            <div class="option">
                                <input type="checkbox" id="q2d" name="q2" value="D">
                                <label for="q2d">D. 抽象</label>
                            </div>
                        </div>

                        <!-- 判断题 -->
                        <div class="question-card">
                            <div class="question-number">3. 判断题 (10分)</div>
                            <div class="question-content">Java是一种编译型语言。</div>
                            <div class="option">
                                <input type="radio" id="q3a" name="q3" value="A">
                                <label for="q3a">A. 正确</label>
                            </div>
                            <div class="option">
                                <input type="radio" id="q3b" name="q3" value="B">
                                <label for="q3b">B. 错误</label>
                            </div>
                        </div>

                        <!-- 简答题 -->
                        <div class="question-card">
                            <div class="question-number">4. 简答题 (25分)</div>
                            <div class="question-content">请简述Java中多态的概念和实现方式。</div>
                            <textarea class="form-control" rows="5" placeholder="请在此处作答..." name="q4"></textarea>
                        </div>

                        <div class="d-flex justify-content-between">
                            <button type="button" class="btn btn-secondary" onclick="history.back()">返回</button>
                            <button type="submit" class="btn btn-primary" id="submitBtn">提交试卷</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
<footer class="bg-light text-center text-muted mt-5 py-3">
    <div class="container">
        <p>© 2025 学生考试管理系统 | 由管理员分配账户</p>
    </div>
</footer>

<script>
    // 考试倒计时
    function startTimer() {
        let timeLeft = 120 * 60; // 120分钟，单位：秒

        const timerElement = document.getElementById('examTimer');

        const timer = setInterval(() => {
            timeLeft--;

            const hours = Math.floor(timeLeft / 3600);
            const minutes = Math.floor((timeLeft % 3600) / 60);
            const seconds = timeLeft % 60;

            timerElement.textContent = `剩余时间: ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;

            if (timeLeft <= 0) {
                clearInterval(timer);
                alert('考试时间已结束，系统将自动提交试卷！');
                document.getElementById('submitBtn').click();
            }
        }, 1000);
    }

     // 页面加载时启动计时器